# Contributor: rubicon <rubicon@mailo.com>
# Maintainer:
pkgname=ocaml-eqaf
_pkgname=eqaf
pkgver=0.8
pkgrel=1
pkgdesc="Constant-time equal function on string"
url="https://github.com/mirage/eqaf"
arch="all !riscv64"  # limited by ocaml aport
license="MIT"
depends="ocaml-runtime ocaml-cstruct"
depends_dev="$pkgname=$pkgver-r$pkgrel ocaml-cstruct-dev"
makedepends="$depends_dev dune ocaml"
checkdepends="ocaml-alcotest-dev ocaml-base64-dev ocaml-crowbar-dev"
options="!check"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.bz2::https://github.com/mirage/eqaf/releases/download/v$pkgver/eqaf-v$pkgver.tbz"
builddir="$srcdir/$_pkgname-v$pkgver"
_ocamldir=usr/lib/ocaml

# 32-bit archs
case "$CARCH" in
	arm*|x86) options="$options textrels" ;;
esac

build() {
	dune build --release --verbose
}

check() {
	dune runtest --verbose
}

package() {
	dune install \
		--destdir="$pkgdir" \
		--docdir=/.omit
	rm -Rf "$pkgdir"/.omit
}

dev() {
	default_dev

	cd "$pkgdir"

	local path; for path in $(find $_ocamldir \( \
			-name '*.cmt' -o \
			-name '*.cmti' -o \
			-name '*.cmx' -o \
			-name '*.cmxa' -o \
			-name '*.ml' -o \
			-name '*.mli' \
		\))
	do
		amove "$path"
	done
}

sha512sums="
303749bdbaae8fc27f57ebaa5cf9b16ed5b8cbaee35f0a35d69f91a437b1a3411a613d145d3aff7ff74a587509d877cc0a569fdae4d00cec65bf50d705361e25  ocaml-eqaf-0.8.tar.bz2
"
